﻿using System;
using System.Windows;
using System.Windows.Data;

namespace tumblr.Converters
{
    public class BoolToInvisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool isInvisible;
            if (value == null || !bool.TryParse(value.ToString(), out isInvisible))
                return Visibility.Visible;

            if (isInvisible)
                return Visibility.Collapsed;
            else
                return Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
